Writing Interactive Fiction with Twine (SHARLA SORGE's Library) by Melissa Ford
Author:Melissa Ford
Language: eng
Format: epub
Publisher: Que Publishing
Published: 2016-02-29T16:00:00+00:00
Adding Values to the Datamap
You assign values to the string indexes in the datamap much the same way you add values to an array. Here’s an example:
Click here to view code image
(set: $character1 to it + (datamap: "Class", "Wizard"))
Later in this chapter, I’ll teach you a second syntax you can use to add values to an index, but this first way should help you to see the fact that you have string indexes and string or numerical values assigned to those indexes.
The first word in the pair ("Class") is the data name. It is the name of the index. The second word in the pair ("Wizard") is the data value. It is the value assigned to that index. For each entry in the datamap, you have a data name and a data value. You cannot have a data name without a data value, and you cannot have a data value without a data name.
In this example, because the variable name—$character1—is so long, you may opt to use a Twine shortcut. I know, I know, I’m usually against Twine shortcuts like abbreviating the (array:) macro to (a:), but in this case, having to type a variable name that long twice every time you add a new value will take up a lot of space.
As a shortcut, you can use the keyword it to stand in for the second instance of the variable name. Because $character1 has already been set in the expression, you can refer to it with the keyword it other times within the same operation. You can’t just throw it willy-nilly into a later operation, such as (set: it to 3). But if the object being changed is already defined in the operation, you can use it to refer to it rather than write out the variable a second time.
In other words, (set: $character1 to it + (datamap: "Class", "Wizard")) is the same as (set: $character1 to $character1 + (datamap: "Class", "Wizard")).
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12589)
Hello! Python by Anthony Briggs(9926)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9800)
The Mikado Method by Ola Ellnestam Daniel Brolund(9786)
Dependency Injection in .NET by Mark Seemann(9347)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7771)
Grails in Action by Glen Smith Peter Ledbrook(7704)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7566)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7152)
Microservices with Go by Alexander Shuiskov(6915)
Practical Design Patterns for Java Developers by Miroslav Wengner(6833)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6774)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6423)
Angular Projects - Third Edition by Aristeidis Bampakos(6191)
The Art of Crafting User Stories by The Art of Crafting User Stories(5711)
NetSuite for Consultants - Second Edition by Peter Ries(5642)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5453)
Kotlin in Action by Dmitry Jemerov(5073)
